/*
origin glsl source: 
#define CC_DEVICE_SUPPORT_FLOAT_TEXTURE 0
#define CC_ENABLE_CLUSTERED_LIGHT_CULLING 0
#define CC_DEVICE_MAX_VERTEX_UNIFORM_VECTORS 4096
#define CC_DEVICE_MAX_FRAGMENT_UNIFORM_VECTORS 1024
#define CC_DEVICE_CAN_BENEFIT_FROM_INPUT_ATTACHMENT 0
#define CC_PLATFORM_ANDROID_AND_WEBGL 0
#define CC_ENABLE_WEBGL_HIGHP_STRUCT_VALUES 0
#define CC_JOINT_UNIFORM_CAPACITY 256
#define CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS 6
#define CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS 1

precision mediump float;
attribute vec2 a_position;
attribute vec2 a_texCoord;
varying vec2 v_uv;
  uniform vec4 u_buffer0;
  uniform vec4 u_buffer1;
  uniform mat4 u_projection;
vec4 vert () {
  vec2 worldPos = a_position * u_buffer1.xy + u_buffer1.zw;
  vec2 clipSpace = worldPos / u_buffer0.xy * 2.0 - 1.0;
  vec4 screenPos = u_projection * vec4(clipSpace, 0.0, 1.0);
  v_uv = a_texCoord;
  return screenPos;
}
void main() { gl_Position = vert(); }
*/
export let glsl_54af2f67072b6ebac70dfb10e1134542 = `#define CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS 1
#define CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS 6
#define CC_JOINT_UNIFORM_CAPACITY 256
#define CC_ENABLE_WEBGL_HIGHP_STRUCT_VALUES 0
#define CC_PLATFORM_ANDROID_AND_WEBGL 0
#define CC_DEVICE_CAN_BENEFIT_FROM_INPUT_ATTACHMENT 0
#define CC_DEVICE_MAX_FRAGMENT_UNIFORM_VECTORS 1024
#define CC_DEVICE_MAX_VERTEX_UNIFORM_VECTORS 4096
#define CC_ENABLE_CLUSTERED_LIGHT_CULLING 0
#define CC_DEVICE_SUPPORT_FLOAT_TEXTURE 0

precision mediump float;
attribute vec2 a_position;
attribute vec2 a_texCoord;
varying vec2 v_uv;
  uniform vec4 u_buffer0;
  uniform vec4 u_buffer1;
  uniform mat4 u_projection;
vec4 vert () {
  vec2 worldPos = a_position * u_buffer1.xy + u_buffer1.zw;
  vec2 clipSpace = worldPos / u_buffer0.xy * 2.0 - 1.0;
  vec4 screenPos = u_projection * vec4(clipSpace, 0.0, 1.0);
  v_uv = a_texCoord;
  return screenPos;
}
void main() { gl_Position = vert(); }
`
import {
    vec4_V2_N_N,
    sampler2D,
    samplerCube,
    float,
    float_N,
    bool,
    bool_N,
    int_N,
    int,
    vec4,
    vec3,
    vec2,
    mat2,
    mat3,
    mat4,
} from "../builtin/BuiltinFunc"
import {
    glSet_V2_V2,
    glMul_V2_V2,
    glAdd_V2_V2,
    glDiv_V2_V2,
    glMul_V2_N,
    glSub_V2_N,
    glSet_V4_V4,
    glMul_M4_V4,
    getValueKeyByIndex,
    getOutValueKeyByIndex,
} from "../builtin/BuiltinOperator"
import {
    gl_FragData,
    gl_FragColor,
    gl_Position,
    gl_PointSize,
    gl_FragCoord,
    gl_FragDepth,
    gl_FrontFacing,
    custom_isDiscard,
} from "../builtin/BuiltinVar"
import { cpuRenderingContext } from "../../CpuRenderingContext"
import {
    AttributeData,
    FragShaderHandle,
    UniformData,
    VaryingData,
    ShaderLocalData,
    VertShaderHandle,
    StructData,
} from "../../ShaderDefine"
import {
    IntData,
    FloatData,
    Vec2Data,
    Vec3Data,
    Vec4Data,
    Mat2Data,
    Mat3Data,
    Mat4Data,
    BoolData,
    Sampler2D,
    SamplerCube,
} from "../builtin/BuiltinData"
let CC_DEVICE_SUPPORT_FLOAT_TEXTURE = new FloatData(0)
let CC_ENABLE_CLUSTERED_LIGHT_CULLING = new FloatData(0)
let CC_DEVICE_MAX_VERTEX_UNIFORM_VECTORS = new FloatData(4096)
let CC_DEVICE_MAX_FRAGMENT_UNIFORM_VECTORS = new FloatData(1024)
let CC_DEVICE_CAN_BENEFIT_FROM_INPUT_ATTACHMENT = new FloatData(0)
let CC_PLATFORM_ANDROID_AND_WEBGL = new FloatData(0)
let CC_ENABLE_WEBGL_HIGHP_STRUCT_VALUES = new FloatData(0)
let CC_JOINT_UNIFORM_CAPACITY = new FloatData(256)
let CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS = new FloatData(6)
let CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS = new FloatData(1)
class AttributeDataImpl implements AttributeData {
    a_position: Vec2Data = new Vec2Data()
    a_texCoord: Vec2Data = new Vec2Data()
    dataKeys: Map<string, any> = new Map([
        ["a_position", cpuRenderingContext.cachGameGl.FLOAT_VEC2],
        ["a_texCoord", cpuRenderingContext.cachGameGl.FLOAT_VEC2],
    ])
    dataSize: Map<string, number> = new Map([
        ["a_position", 1],
        ["a_texCoord", 1],
    ])
}
class VaryingDataImpl extends VaryingData {
    v_uv: Vec2Data = new Vec2Data()

    factoryCreate() {
        return new VaryingDataImpl()
    }
    dataKeys: Map<string, any> = new Map([["v_uv", cpuRenderingContext.cachGameGl.FLOAT_VEC2]])
    copy(varying: VaryingDataImpl) {
        glSet_V2_V2(varying.v_uv, this.v_uv)
    }
}
class UniformDataImpl implements UniformData {
    u_buffer0: Vec4Data = new Vec4Data()
    u_buffer1: Vec4Data = new Vec4Data()
    u_projection: Mat4Data = new Mat4Data()
    dataKeys: Map<string, any> = new Map([
        ["u_buffer0", cpuRenderingContext.cachGameGl.FLOAT_VEC4],
        ["u_buffer1", cpuRenderingContext.cachGameGl.FLOAT_VEC4],
        ["u_projection", cpuRenderingContext.cachGameGl.FLOAT_MAT4],
    ])
    dataSize: Map<string, number> = new Map([
        ["u_buffer0", 1],
        ["u_buffer1", 1],
        ["u_projection", 1],
    ])
}
class ShaderLocalDataImpl implements ShaderLocalData {
    dataKeys: Map<string, any> = new Map([])
    dataSize: Map<string, number> = new Map([])
    init() {}
}
export class Impl_54af2f67072b6ebac70dfb10e1134542 extends VertShaderHandle {
    varyingData: VaryingDataImpl = new VaryingDataImpl()
    uniformData: UniformDataImpl = new UniformDataImpl()
    attributeData: AttributeDataImpl = new AttributeDataImpl()

    vert(): Vec4Data {
        let worldPos: Vec2Data = vec2()
        glSet_V2_V2(
            worldPos,
            glAdd_V2_V2(glMul_V2_V2(this.attributeData.a_position, this.uniformData.u_buffer1.xy), this.uniformData.u_buffer1.zw)
        )
        let clipSpace: Vec2Data = vec2()
        glSet_V2_V2(clipSpace, glSub_V2_N(glMul_V2_N(glDiv_V2_V2(worldPos, this.uniformData.u_buffer0.xy), float_N(2.0)), float_N(1.0)))
        let screenPos: Vec4Data = vec4()
        glSet_V4_V4(screenPos, glMul_M4_V4(this.uniformData.u_projection, vec4_V2_N_N(clipSpace, float_N(0.0), float_N(1.0))))
        glSet_V2_V2(this.varyingData.v_uv, this.attributeData.a_texCoord)
        return screenPos
    }
    main(): void {
        glSet_V4_V4(gl_Position, this.vert())
    }
}
